<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex flex-direction flex-wrap align-stretch benben-position-layout flex bindAlipay_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between bindAlipay_fd0_0'>
					<view class='flex flex-wrap align-center bindAlipay_fd0_0_c0' @tap.stop="handleJumpDiy"
						data-type="back" data-url="1">
						<text class='fu-iconfont2  bindAlipay_fd0_0_c0_c0'>&#xE794;</text>
					</view>
					<view class='flex flex-wrap align-center'>
						<text class='bindAlipay_fd0_0_c1_c0'>绑定支付宝</text>
					</view>
					<view class='flex align-center justify-end bindAlipay_fd0_0_c0'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>

			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout bindAlipay_flex_1">
				<view class='flex flex-wrap align-center bindAlipay_fd1_0'>
					<text class='bindAlipay_fd1_0_c0'>第一步：先获取手机验证码</text>
				</view>
				<view class='flex flex-direction flex-wrap align-stretch bindAlipay_fd1_1'>
					<view class='flex flex-wrap align-center bindAlipay_fd1_1_c0'>
						<text class='bindAlipay_fd1_1_c0_c0'>绑定的用户手机</text>
						<text class='bindAlipay_fd1_1_c0_c0'>{{userInfo.mobile}}</text>
					</view>
					<view class='flex flex-wrap align-center bindAlipay_fd1_1_c1'>
						<text class='bindAlipay_fd1_1_c1_c0'>验证码</text>
						<benben-input class='flex-sub bindAlipay_fd1_1_c1_c1' type="number" :placeholder="`请输入验证码`"
							confirm-type="done" :maxlength="4" placeholder-style="color:#BFBFBF;font-size:28rpx"
							v-model="code" />
						<benben-send-verification-code key='1686917612135' ref="vCode1686917612135"
							class=' bindAlipay_fd1_1_c1_c2' after-text='后重新获取' before-text='获取验证码' type='3'
							:phone="userInfo.phone"></benben-send-verification-code>
					</view>
				</view>
				<view class='flex flex-wrap align-center bindAlipay_fd1_1_c0'>
					<text class='bindAlipay_fd1_0_c0'>第二步：上传支付宝收款二维码</text>
				</view>
				<view class='flex flex-direction flex-wrap align-start bindAlipay_fd1_3'>
					<view class='flex flex-wrap align-center'>
						<view class="upload position-relative bindAlipay_fd1_3_c0_c0">
							<text v-if="alipayData.qrcode_url != ''" @tap="alipayData.qrcode_url = ''"
								class='fu-iconfont2 position-absolute bindAlipay_fd1_3_c0_c0_icon'>&#xE8E7;</text>
							<image class=" bindAlipay_fd1_3_c0_c0" mode="aspectFill"
								@tap="soloChooseImage('qrcode_url','qrcode_url',alipayData,alipayData)"
								:src="alipayData.qrcode_url ? alipayData.qrcode_url : STATIC_URL+'64.png'">
							</image>
						</view>
					</view>
					<text class='bindAlipay_fd1_3_c1'>上传二维码</text>
				</view>
				<view class='flex flex-wrap align-center bindAlipay_fd1_1_c0'>
					<text class='bindAlipay_fd1_0_c0'>第三步：填写支付宝真实姓名</text>
				</view>
				<view class='flex flex-wrap align-center bindAlipay_fd1_5'>
					<text class='bindAlipay_fd1_5_c0'>真实姓名</text>
					<benben-input class='flex-sub bindAlipay_fd1_1_c1_c1' type="text" :placeholder="`请输入真实姓名`"
						confirm-type="done" :maxlength="50" placeholder-style="color:#BFBFBF;font-size:28rpx"
						v-model="alipayData.real_name" />
				</view>
			</view>


			<view class="flex flex-direction flex-wrap align-center benben-position-layout flex bindAlipay_flex_2">
				<button class='bindAlipay_fd2_0' @tap.stop="postBindPhoneFunc()">提交</button>

			</view>
			<view :style="{height: '128rpx'}"></view>


		</view>
	</view>
</template>
<script>
	import UploadImage from '@/common/utils/upload-image.js'
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},


		data() {
			return {
				"code": "",
				"alipayData": {
					"aid": "",
					"is_default": "",
					"create_time": "",
					"update_time": "",
					"status": "",
					"real_name": "",
					"account": "",
					"qrcode_url": "",
					"bank_name": "",
					"bank_address": "",
					"remark": ""
				}
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},
			userInfo: {
				get() {
					return this.$store.state.userInfo
				},
				set() {
					this.$store.commit('updateUserInfo', value)
				},
			},
			/**
			 * @returns 
			 * Android       安卓
			 * IOS       苹果
			 * Web       H5 或 pc
			 * Wechat       微信小程序
			 * Alipay       支付宝小程序
			 * Baidu       百度小程序
			 * ByteBounce       抖音小程序
			 * 360       360小程序
			 * FastApp       快应用
			 */
			appSystemIdentification() {
				return this.$store.state.appSystemIdentification
			}
		},
		watch: {},
		onLoad(options) {
			this.getAlipayFunc()
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//上传单图、多图方法
			soloChooseImage(id, path, obj, obj1, fnName = false) {
				if (!this.setCheckPermission(2)) {
					return
				}
				let self = this
				if (!obj) obj = this
				if (!obj1) obj1 = this
				if (self.uploading) {
					return
				}
				// 从相册中选择图片
				uni.chooseImage({
					count: 1, // 默认3
					sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
					success: function(res) {
						self.uploading = true
						// 开始上传
						new UploadImage(res.tempFiles, {
							complete: function(res) {
								self.uploading = false
								if (id) self.$set(obj, id, res[0].id)
								if (path) self.$set(obj1, path, res[0].path)
								if (fnName) self[fnName]()
							},
						})
					},
				})
			},
			//提交绑定手机号
			async postBindPhoneFunc() {
				if (!validate(this.code, 'require')) {
					this.$message.info('验证码不能为空');
					return false;
				}
				if (!validate(this.code, 'captcha')) {
					this.$message.info('验证码格式不正确');
					return false;
				}
				if (!validate(this.alipayData.qrcode_url, 'require')) {
					this.$message.info('请上传收款二维码');
					return false;
				}
				if (!validate(this.alipayData.real_name, 'require')) {
					this.$message.info('请输入真实姓名');
					return false;
				}
				if (this.$util.antiShakeThrottle()) return
				//请求方法
				//数据验证

				let data5f6db4db8abcf = await this.$api.post(global.apiUrls.post5f6db4db8abcf, {
					mobile: this.userInfo.phone,
					code: this.code,
					type: '3'
				});

				if (data5f6db4db8abcf.data.code != 1) {
					this.$message.info(data5f6db4db8abcf.data.msg);
					return
				}



				//请求方法
				//数据验证

				let data636cc0cc8d6cc = await this.$api.post(global.apiUrls.post636cc0cc8d6cc, {
					real_name: this.alipayData.real_name,
					account_type: 'alipay',
					qrcode_url: this.alipayData.qrcode_url
				});

				if (data636cc0cc8d6cc.data.code != 1) {
					this.$message.info(data636cc0cc8d6cc.data.msg);
					return
				}



				this.$message.info('绑定成功');
				setTimeout(() => {
					this.$urouter.navigateBack(1);
				}, 500)
			},
			//获取支付宝信息
			async getAlipayFunc() {
				//请求方法
				//数据验证

				let dataalipayData = await this.$api.get(global.apiUrls.post636cbb376d5d8, {
					account_type: 'alipay'
				});

				if (dataalipayData.data.code != 1) {
					this.$message.info(dataalipayData.data.msg);
					return
				}
				let infoalipayData = dataalipayData.data;
				this.alipayData = infoalipayData.data

			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto;
	}

	.bindAlipay_flex_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.bindAlipay_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333333;
	}

	.bindAlipay_fd0_0_c0_c0 {
		font-size: 36rpx;
		color: #333;
		font-weight: 500;
	}

	.bindAlipay_fd0_0_c0 {
		width: 100rpx;
	}

	.bindAlipay_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
	}

	.bindAlipay_flex_1 {
		background: #fff;
		padding: 0rpx 32rpx 0rpx 32rpx;
		background-size: 100% auto !important;
	}

	.bindAlipay_fd1_5_c0 {
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(102, 102, 102, 1);
		margin: 0rpx 32rpx 0rpx 0rpx;
	}

	.bindAlipay_fd1_5 {
		padding: 0rpx 0rpx 32rpx 0rpx;
		line-height: 48rpx;
	}

	.bindAlipay_fd1_3_c1 {
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(102, 102, 102, 1);
		margin: 24rpx 0rpx 0rpx 0rpx;
	}

	.bindAlipay_fd1_3_c0_c0_icon {
		top: 0rpx;
		right: 0rpx;
		z-index: 10;
		color: #ff5536;
	}

	.bindAlipay_fd1_3_c0_c0 {
		width: 160rpx;
		height: 160rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	.bindAlipay_fd1_3 {
		border-bottom: 1px solid #eee;
		padding: 0rpx 0rpx 32rpx 0rpx;
		margin: 0rpx 0rpx 40rpx 0rpx;
	}

	.bindAlipay_fd1_1_c1_c2 {
		text-align: center;
		font-size: 28rpx;
		color: rgba(87, 174, 251, 1);
		font-weight: 400;
	}

	.bindAlipay_fd1_1_c1_c1 {
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(51, 51, 51, 1);
	}

	.bindAlipay_fd1_1_c1_c0 {
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(102, 102, 102, 1);
		margin: 0rpx 24rpx 0rpx 0rpx;
	}

	.bindAlipay_fd1_1_c1 {
		border-bottom: 1px solid #eee;
		padding: 0rpx 0rpx 32rpx 0rpx;
	}

	.bindAlipay_fd1_1_c0_c0 {
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(102, 102, 102, 1);
	}

	.bindAlipay_fd1_1_c0 {
		margin: 0rpx 0rpx 32rpx 0rpx;
	}

	.bindAlipay_fd1_1 {
		margin: 0rpx 0rpx 40rpx 0rpx;
	}

	.bindAlipay_fd1_0_c0 {
		font-size: 28rpx;
		font-weight: 500;
		color: rgba(51, 51, 51, 1);
	}

	.bindAlipay_fd1_0 {
		padding: 40rpx 0rpx 32rpx 0rpx;
	}

	.bindAlipay_flex_2 {
		width: 750rpx;
		height: 128rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
	}

	.bindAlipay_fd2_0 {
		background: var(--benbenbgColor0);
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: #fff;
		width: 686rpx;
		height: 88rpx;
		line-height: 88rpx;
		font-weight: 500;
	}
</style>